package com.orange.cepmanager.android;

import com.orange.cepmanager.android.tools.GpsLocation;
import com.orange.cepmanager.android.tools.ImageLoader;

import android.annotation.TargetApi;
import android.app.Application;
import android.content.Context;
import android.os.StrictMode;


@TargetApi(9)
public class CEPManagerApplication extends Application {
	public static final String TAG = CEPManagerCommon.CEPMANAGER_TAG;
	private ImageLoader mImageLoader = null;
	public static final String PREFS = "";
	private static CEPManagerApplication instance = null;
	private static Context context = null;
	private Boolean mReachable = null;
	private final static String SERVER_URL = "";

	public static CEPManagerApplication getInstance() {
		if (instance == null) {
			throw new IllegalStateException("Application not created yet!");
		}

		return instance;
	}

	@Override
	public void onCreate() {
		instance = this;
		context = getApplicationContext();
		if (android.os.Build.VERSION.SDK_INT > 9) {
			StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
			StrictMode.setThreadPolicy(policy);
		}

		GpsLocation.initLocationManager();
		// applyPreferences();
	}

	public static Context getAppContext() {
		return context;
	}

	
	/**
	 * Public accessor for image-loader, so all activities all use the same
	 * instance.
	 * 
	 * @return ImageLoader
	 */
	public ImageLoader getImageLoader() {
		if (mImageLoader == null) {
			mImageLoader = new ImageLoader(this);
		}

		return mImageLoader;
	}
}
